package com.bdqn.zhang.controller;

import com.bdqn.zhang.pojo.SysUser;
import com.bdqn.zhang.service.UserService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: tao
 * @Description: talk is cheap,show me the code!
 * @Date: create in 2020/11/23 10:09
 */

/* 表明所有方法都是异步方法*/
@RestController
@RequestMapping("/user")
public class UserController {

//    @Resource
//    private Student student;

    @Autowired
    private UserService userService;

    /*@RequestMapping("/hello")
    public String hello(){
        System.out.println(Global.getName());

        int count = userService.count();

        return String.valueOf(count);
    }*/

    /**
     * 查询所有用户信息
     * @param id
     * @return
     */
    @ApiOperation(value="获取用户列表信息", notes="获取用户列表信息")
    @GetMapping("/list")
    public List<SysUser> getUserList(){
        //System.out.println(1/0);
        return userService.getUserList();
    }


    @ApiOperation(value = "添加用户",notes = "添加用户")
    @ApiImplicitParam(name = "user",value = "用户详细实体user", required = true, dataType =
            "SysUser")
    @PostMapping("/save")
    public String getUserList(SysUser user){
        return String.valueOf(userService.add(user));
    }
}
